import axios from "axios";

const BASE_URL = "http://localhost:8080/ssm_project_annotation_war/";

const api = axios.create({
    baseURL: BASE_URL,
    withCredentials: true, // 设置为 true 以处理跨域请求的凭证信息
    timeout: 50000000
})

/**
 * 封装post请求
 * @param url 地址
 * @param params 参数
 * @param warning 是否警告
 * @param headers header
 * @param tokenNeed 是否需要token
 * @returns {Promise<any>}
 */
api.doPost = async function (url, params, headers = {}) {
    let response = await api.post(url, params, {headers});
    return response.data;
}
/**
 * 封装get请求
 * @param url 地址
 * @param warning 是否警告
 * @param headers header
 * @param tokenNeed 是否需要token
 * @returns {Promise<any>}
 */
api.doGet = async function (url, headers = {}) {
    let response = await api.get(url, {headers});
    return response.data;
}

export default api;